package com.blockmeta.bbs.minemodule.activity;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.blockmeta.bbs.baselibrary.provider.IApplicationProvider;
import com.blockmeta.bbs.baselibrary.utils.SharedPreferenceUtil;
import com.blockmeta.bbs.baselibrary.utils.ToastUtil;
import com.blockmeta.bbs.businesslibrary.arouter.RouterHelper;
import com.blockmeta.bbs.businesslibrary.arouter.RouterPath;
import com.blockmeta.bbs.businesslibrary.base.BaseActivity;
import com.blockmeta.bbs.businesslibrary.constant.Constant;
import com.blockmeta.bbs.minemodule.BuildConfig;
import com.blockmeta.bbs.minemodule.R;

/**
 * Created by author on 2018/1/30.
 */

public class AboutUsActivity extends BaseActivity implements View.OnClickListener {

    private TextView tv;
    private String versionName;
    private View v;

    @Override
    protected boolean showTitle() {
        return true;
    }

    @Override
    public View setView() {
        setTitleText("关于我们");
        v = LayoutInflater.from(this).inflate(R.layout.activity_aboutus1, null);
        tv = (TextView) v.findViewById(R.id.aboutus_tv);
        IApplicationProvider provider = RouterHelper.getProvider(RouterPath.APPLICATION_PROVIDER);
        tv.setText(provider.getProjectBuildInfo().version_name);
        v.findViewById(R.id.tv_user_agreement).setOnClickListener(this);
        v.findViewById(R.id.tv_user_privacy).setOnClickListener(this);
        initData();
        return v;
    }

    private void initData() {
        ImageView img = (ImageView) v.findViewById(R.id.aboutus_img);
        img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String xgToken = SharedPreferenceUtil.getString(mContext, Constant.GETUI_TOKEN, "");
                ClipboardManager cm = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
                ClipData mClipData = ClipData.newPlainText("复制文字", xgToken);
                cm.setPrimaryClip(mClipData);
                ToastUtil.show("copy");
            }
        });

        TextView changVersion = v.findViewById(R.id.changeVersion);
        changVersion.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            }
        });

    }

    @Override
    public void onClick(View v) {
        if (v.getId()==R.id.tv_user_agreement){
            RouterHelper.startActivity(mContext,RouterPath.WEB_ACTIVITY,mContext.getResources().getString(R.string.user_login_protocol_url));
        }else if (v.getId()==R.id.tv_user_privacy){
            RouterHelper.startActivity(mContext,RouterPath.WEB_ACTIVITY,mContext.getResources().getString(R.string.privacy_agreement_url));
        }
    }
}
